package com.entor.springboot201912.controller;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.bind.annotation.InitBinder;

import java.text.SimpleDateFormat;
import java.util.Date;

@Controller
public class BaseController {
    @InitBinder
    public void initBinder(ServletRequestDataBinder binder){
        /*
         * 自动时间转换器
         */
        binder.registerCustomEditor(Date.class,new CustomDateEditor(
                new SimpleDateFormat("yyyy-MM-dd"),true
        ));
    }
}
